import Vue    from 'vue'
import Router from 'vue-router'
import Home   from '@/components/home'
import Login  from '@/components/login'
// process.env.NODE_ENV此环境变量在启动的时候指定环境了（文件为.env.development在启动命令中），可以直接使用
const _import = require('./_import_' + process.env.NODE_ENV)

Vue.use(Router)

export const constantRouterMap = [
	{ path: '/login', component: Login, hidden: true },
	{
	 path: '/home',
	 component: Home,
	 redirect: '/home/detail',
	 children: [ 
	 	{
	 	path: 'detail',
	    component: _import('customerInfo'),
	    name: 'details',
	    meta: { title: '首页详情', icon: 'dashboard', noCache: true }
		}
	  ]
	},
	{
	 meta: { title: '客户管理', icon: 'dashboard', noCache: true },
	 path: '/customer',
	 component: Home,
	 redirect: '/customer',
	 children: [ 
	 	{
	 	path: 'customerInfo',
	    component: _import('customerInfo'),
	    name: 'customerInfos',
	    meta: { title: '客户信息', icon: 'dashboard', noCache: true }
		},
		{
	 	path: 'houseInfo',
	    component: _import('customerInfo'),
	    name: 'houseInfos',
	    meta: { title: '房源信息', icon: 'dashboard', noCache: true }
		}
	  ]
	}

]


export default new Router({
	scrollBehavior: () => ({ y: 0 }),
 	routes: constantRouterMap
}
)

export const asyncRouterMap = []